<template>
	<view>
		<view class="nearbySites">
			<view class="siteCon">
				<view class="siteList" v-for="item in nearList">
					<view class="slist_top">
						<view class="slist_left">
							<view>{{item.name}}</view>
							<view>地址：{{item.address}}</view>
						</view>
						<view class="slist_right" @click="goMap(item)">
							<image src="../../static/icons/nc_30.png" mode=""></image>
						</view>
					</view>
					<view class="slist_add">
						<text class="distance">约<text>{{item.juli}}km</text></text>
						<text class="contactName">联系人:{{item.contacts}}</text>
						<text class="contactTel">电话:{{item.tel}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				longitude:"",
				latitude:"",
				nearList:[],
			}
		},
		methods: {
			goMap(item) {
				uni.openLocation({
					longitude:Number(item.lng),
					latitude:Number(item.lat),
					name:item.address
					})
			},
			getNearList() {
				this.$get('index/storelist', {
					page:1,
					pagesize:100,
					lng:this.longitude,
					lat:this.latitude,
				}, (res) => {
					this.nearList = res.list
				})
			},
		},
		onLoad() {
			uni.getLocation({
				type: 'wgs84',
				success: (res) => {
					console.log(res)
					this.longitude = res.longitude;
					this.latitude = res.latitude;
					this.getNearList()
				}
			});
		},
	}
</script>

<style>
	.nearbySites {
		width: 710rpx;
		/* background: #fff; */
		margin: 0 auto;
		padding-top: 20rpx;
	}
	.siteName {
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 36rpx 0;
	}
	
	.siteName .sname {
		font-size: 34rpx;
		font-family: PingFang;
		font-weight: bold;
		color: #333333;
		position: relative;
	}
	
	.siteList {
		width: 100%;
		height: 220rpx;
		border-radius: 20rpx;
		border: 1rpx solid #efeff0;
		background: #fff;
		padding: 40rpx 40rpx 43rpx;
		margin-bottom: 38rpx;
		box-shadow: 1px 1px 9px 3px #efeff0;
	}
	
	.slist_top {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin-top: 10rpx;
	}
	.slist_left {
		width: 440rpx;
	}
	.slist_left view:first-child {
		color: #484848;
		font-size: 33rpx;
		margin-bottom: 14rpx;
	}
	.slist_left view:last-child {
		color: #9b9b9b;
		font-size: 24rpx;
	}
	.slist_right {
		flex: 1;
	}
	.slist_right image {
		width: 146rpx;
		height: 57rpx;
	}
	.slist_add {
		font-size: 24rpx;
		color: #b1b1b1;
	}
	.distance {
		position: relative;
		margin-right: 35rpx;
	}
	.distance text {
		color: #00bb66;
		font-weight: bold;
		font-size: 44rpx;
		margin: 0 4rpx;
	}
	.distance::after {
		content: '';
		position: absolute;
		height: 25rpx;
		background: #c8c8c8;
		width: 2rpx;
		right: -18rpx;
		top: 50%;
		margin-top: -12rpx;
	}
	.contactName {
		margin-right: 30rpx;
	}
	.bottomLine::after {
		content: '';
		position: absolute;
		height: 10rpx;
		background: #f7f7f7;
		width: 750rpx;
		left: -30rpx;
		right: 0;
		bottom: 0;
	}
	
</style>
